/**
 * StarInfoFrameUnexplored.java
 *
 * Roslan's Remake of MOO in 3D using Ardor3D
 * (C) 2010-2012 Roslan Amir. All rights reserved.
 */

package name.roslan.games.moo3d.ui;

import name.roslan.games.moo3d.data.Star;
import name.roslan.games.moo3d.spatial.StarNode;

import com.ardor3d.extension.ui.UILabel;
import com.ardor3d.extension.ui.UIPanel;
import com.ardor3d.extension.ui.backdrop.ImageBackdrop;
import com.ardor3d.extension.ui.util.SubTex;
import com.ardor3d.image.Texture;
import com.ardor3d.util.TextureManager;

/**
 * This info node displays the information about the currently selected Star which has not been explored.
 * 
 * @author Roslan Amir
 * @version 1.0 - Aug 9, 2011
 */
public class StarInfoFrameUnexplored extends StarInfoFrameBase {

    private static final String IMAGE_UNEXPLORED_YELLOW = "images/unexplored-yellow.jpg";

    private static final String IMAGE_UNEXPLORED_GREEN = "images/unexplored-green.jpg";

    private static final String IMAGE_UNEXPLORED_RED = "images/unexplored-red.jpg";

    private static final String IMAGE_UNEXPLORED_WHITE = "images/unexplored-white.jpg";

    private static final String IMAGE_UNEXPLORED_BLUE = "images/unexplored-blue.jpg";

    private static final String IMAGE_UNEXPLORED_NEUTRON = "images/unexplored-neutron.jpg";

    /**
     * 
     */
    private static final ImageBackdrop[] BACKDROP_STAR_DESCRIPTION = new ImageBackdrop[Star.STAR_DESCRIPTION.length];

    /*
     * Load the image textures.
     */
    static {
        /*
         * Load the image subtextures and create the backdrops.
         */
        Texture tex = TextureManager.load(IMAGE_UNEXPLORED_YELLOW, Texture.MinificationFilter.Trilinear, false);
        BACKDROP_STAR_DESCRIPTION[0] = new ImageBackdrop(new SubTex(tex));
        tex = TextureManager.load(IMAGE_UNEXPLORED_GREEN, Texture.MinificationFilter.Trilinear, false);
        BACKDROP_STAR_DESCRIPTION[1] = new ImageBackdrop(new SubTex(tex));
        tex = TextureManager.load(IMAGE_UNEXPLORED_RED, Texture.MinificationFilter.Trilinear, false);
        BACKDROP_STAR_DESCRIPTION[2] = new ImageBackdrop(new SubTex(tex));
        tex = TextureManager.load(IMAGE_UNEXPLORED_WHITE, Texture.MinificationFilter.Trilinear, false);
        BACKDROP_STAR_DESCRIPTION[3] = new ImageBackdrop(new SubTex(tex));
        tex = TextureManager.load(IMAGE_UNEXPLORED_BLUE, Texture.MinificationFilter.Trilinear, false);
        BACKDROP_STAR_DESCRIPTION[4] = new ImageBackdrop(new SubTex(tex));
        tex = TextureManager.load(IMAGE_UNEXPLORED_NEUTRON, Texture.MinificationFilter.Trilinear, false);
        BACKDROP_STAR_DESCRIPTION[5] = new ImageBackdrop(new SubTex(tex));
    }

    /**
     * The label for the star's range from the nearest player's colony.
     */
    protected final UILabel rangeValueLabel;

    /**
     * Default no-arg constructor.
     */
    public StarInfoFrameUnexplored() {
        super("Unexplored Star System", null);

        final UIPanel panel = new UIPanel();
        // panel.setLayout(new AnchorLayout());
        // panel.setMargin(InfoFrameBase.MARGINS_ZERO);
        // panel.setPadding(InfoFrameBase.PADDING_2000);
        // panel.setBorder(InfoFrameBase.SOLID_BORDER_TWO);
        infoPanel.add(panel);

        rangeValueLabel = new UILabel("");
        rangeValueLabel.setStyledText(true);
        // rangeValueLabel.setForegroundColor(DEFAULT_FOREGROUND_COLOR);
        // rangeValueLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 7, -135));
        panel.add(rangeValueLabel);
    }

    /**
     * @param starNode
     */
    protected void update(StarNode starNode) {
        infoPanel.setBackdrop(BACKDROP_STAR_DESCRIPTION[starNode.getStar().colorIndex]);
        rangeValueLabel.setText("[b][c=#fff]Range: " + starNode.range + " parsecs[/c][/b]");
        // rangeValueLabel.setText("[c=#fff]Range: " + starNode.range + " parsecs[/c]");

        updateAndpack();
    }

}
